<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>高度塌陷</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background-color: green;
            display: flex;
            align-items: center;
            justify-content: center;
            /* flex-direction: column; */
        }
        .box1 {
            width: 40px;
            height: 40px;
            /* margin-bottom: 10px; */
            background-color: red;
            /* overflow: hidden; */
            /* position: relative; */
            /* flex: inherit; */
            flex: auto;
        }
        .box2 {
            width: 40px;
            height: 40px;
            /* margin-top: 10px; */
            background-color: pink;
            /* overflow: hidden; */

        }
    </style>
</head>
<body>
    <div class="box">
        <div class="box1">1</div>
        <div class="box2">2</div>
    </div>
</body>
</html>